package com.qf.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * @author Ypl
 * @version V1.0
 * @Project OctoberAndNovember
 * @Package com.qf.util
 * @Description:
 * @Date 2022/10/27 11:42
 */
@SuppressWarnings("all")
public class EsClient {

    /**
     * 获取连接对象
     * @return
     */
    public static RestHighLevelClient getClient(){
        //获取连接
        HttpHost httpHost = new HttpHost("192.168.11.100",9200);
        //构建连接
        RestClientBuilder builder = RestClient.builder(httpHost);
        //创建连接对象
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }
}
